#ifndef _ROBOT_H
#define _ROBOT_H

#include "NetWork/NetDef.h"
#include <string>

class NetWork;

class NetObject
{
public:
	enum
	{
		Hearbeat_Internal = 10000,
	};
	NetObject(NetWork& _netWork);
	virtual void ReConnect() = 0;
	virtual void Connect(const char* pIP,int nPort);
	bool IsConnected()const;
	bool IsConnecting()const;
	bool IsDisconnecting()const;
	bool IsStopped()const;

	void DisConnect();
	void heartbeatReponse();
	bool isTimeout()const;
protected:
	NetWork&    m_netWork;
	Client_Con m_pCon;
	int m_lastHeartbeat;
	int m_lastHeartbeatReponse;
	bool       m_isDisconnected;
};
class Robot : public NetObject
{
public:
	enum
	{
		state_none,
		state_logining,
		state_logined,
		state_logout,
	};
	Robot(NetWork& _netWork,const std::string& username,const std::string& password);
	void Tick();
	virtual void ReConnect();
	virtual void Connect(const char* pIP,int nPort);
	void Login();
	void Logout();
	void setstate(int _state);
		int         m_RobotID;
private:
	void Robot_Connected_Handler(int error);
	void Robot_DisConnected_Handler(ConectionID,bool bCanReConnect);

	int         m_packetcount;

	std::string m_username;
	std::string m_password;
	int         m_state;

};
#endif